/*******************************************************************************
 * Copyright (c) 2017 I3S laboratory, INRIA and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     I3S laboratory and INRIA Kairos - initial API and implementation
 *******************************************************************************/
/*
 * generated by Xtext
 */
package org.eclipse.gemoc.execution.moccml.testscenariolang.xtext.formatting;

import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
import org.eclipse.xtext.formatting.impl.FormattingConfig;
import org.eclipse.xtext.Keyword;
import org.eclipse.xtext.util.Pair;

/**
 * This class contains custom formatting description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
 * on how and when to use it 
 * 
 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
 */
public class TestScenarioLangFormatter extends AbstractDeclarativeFormatter {
	
	@Override
	protected void configureFormatting(FormattingConfig c) {
		org.eclipse.gemoc.execution.moccml.testscenariolang.xtext.services.TestScenarioLangGrammarAccess f = (org.eclipse.gemoc.execution.moccml.testscenariolang.xtext.services.TestScenarioLangGrammarAccess) getGrammarAccess();
		c.setAutoLinewrap(120);
		for(Pair<Keyword, Keyword> pair: f.findKeywordPairs("{", "}")) {
			c.setIndentation(pair.getFirst(), pair.getSecond());
			c.setLinewrap(1).after(pair.getFirst());
			c.setLinewrap(1).before(pair.getSecond());
			c.setLinewrap(1).after(pair.getSecond());
		}
		c.setLinewrap(0, 1, 2).before(f.getSL_COMMENTRule());
		c.setLinewrap(0, 1, 2).before(f.getML_COMMENTRule());
		c.setLinewrap(0, 1, 1).after(f.getML_COMMENTRule());
		for (Keyword semicolon : f.findKeywords(";")) {
			c.setNoLinewrap().before(semicolon);
			c.setNoSpace().before(semicolon);
			c.setLinewrap().after(semicolon);
		}
		for (Keyword kw : f.findKeywords("import", "ImportModel", "ImportClass", "importPackage")) {
			c.setNoLinewrap().after(kw);
		}
		for (Keyword colon : f.findKeywords(":")) {
			c.setNoLinewrap().around(colon);
		}
		for (Keyword dot : f.findKeywords(".")) {
			c.setNoSpace().around(dot);
			c.setNoLinewrap().around(dot);
		}
		for (Keyword paren : f.findKeywords("()")) {
			c.setNoLinewrap().before(paren);
			c.setNoSpace().before(paren);
		}
	}
}
